local DIY = require "packages.diy_utility.diy_utility"

local skel = fk.CreateSkill {
  name = "rmt__fengxi",
  tags = {DIY.ReadySkill},
}

Fk:loadTranslationTable{
  ["rmt__fengxi"] = "锋西",
  [":rmt__fengxi"] = "<a href='diy_ready_skill'>蓄势技</a>，出牌阶段，你可以对一名座次大于你和一名体力值大于你的角色各造成1点伤害。"..
  "此技能重置时，你摸三张牌。",

  ["#rmt__fengxi"] = "锋西：对一名座次大于你和一名体力值大于你的角色各造成1点伤害",

  ["$rmt__fengxi1"] = "男儿当封侯，焉能守旧丘。",
  ["$rmt__fengxi2"] = "落日照大旗，出师亘长云！",
}

skel:addEffect("active", {
  anim_type = "offensive",
  card_num = 0,
  min_target_num = 1,
  max_target_num = 2,
  prompt = "#rmt__fengxi",
  can_use = function(self, player)
    return true
  end,
  card_filter = Util.FalseFunc,
  target_filter = function (self, player, to_select, selected)
    if #selected > 1 or (to_select.seat <= player.seat and to_select.hp <= player.hp) then return false end
    local first = selected[1]
    if first then
      if (first.seat <= player.seat) then return to_select.seat > player.seat end
      if (first.hp <= player.hp) then return to_select.hp > player.hp end
    end
    return true
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    room:sortByAction(effect.tos)
    for _, p in ipairs(effect.tos) do
      if not p.dead then
        room:damage{
          from = player,
          to = p,
          damage = 1,
          skillName = skel.name,
        }
      end
    end
  end,
})

skel:addEffect(DIY.SkillReadyFinish, {
  anim_type = "drawcard",
  can_trigger = function (self, event, target, player, data)
    return target == player and data and data.skill.name == skel.name and not player.dead
  end,
  on_cost = Util.TrueFunc,
  on_use = function (self, event, target, player, data)
    player:drawCards(3, skel.name)
  end,
})

return skel
